package de.tud.binpacking.data;

public class Item implements Comparable<Item> {
	
	private int row;
	private int cell;
	private int aisle;
	private int id;
	
	public Item(final int id, final int row, final int cell) {
		this.id = id;
		this.setRow(row);
		this.cell = cell;
	}
	
	public int getRow() {
		return row;
	}
	
	public int getId() {
		return id;
	}
	
	public void setRow(final int row) {
		this.row = row;
		this.aisle = (int) row / 2;
	}
	
	public int getCell() {
		return cell;
	}
	
	public void setCell(final int cell) {
		this.cell = cell;
	}
	
	public int getAisle() {
		return this.aisle;
	}

	@Override
	public int compareTo(final Item position) {
		if (this.getAisle() < position.getAisle()) {
			return -1;
		} else if (this.getAisle() == position.getAisle()) {
			if (this.getCell() < position.getCell()) {
				return -1;
			} else if (this.getCell() == position.getCell()) {
				return 0;
			} else {
				return 1;
			}
		} else {
			return 1;
		}
	}
	
	@Override
	public String toString() {
		return "Item " + id + " (" + row + "/" + cell + ")"; 
	}

}
